package com.ruoyi.demo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.demo.domain.AuctionDeposit;
import com.ruoyi.demo.service.IAuctionDepositService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 竞拍保证金Controller
 *
 * @author metaee
 * @date 2025-03-05
 */
@Api(tags = "竞拍保证金管理")
@RestController
@RequestMapping("/demo/deposit")
public class AuctionDepositController extends BaseController
{
    @Autowired
    private IAuctionDepositService auctionDepositService;

    /**
     * 查询竞拍保证金列表
     */
    @ApiOperation("查询竞拍保证金列表")
    @PreAuthorize("@ss.hasPermi('demo:deposit:list')")
    @GetMapping("/list")
    public TableDataInfo list(AuctionDeposit auctionDeposit)
    {
        startPage();
        List<AuctionDeposit> list = auctionDepositService.selectAuctionDepositList(auctionDeposit);
        return getDataTable(list);
    }

    /**
     * 导出竞拍保证金列表
     */
    @ApiOperation("导出竞拍保证金列表")
    @PreAuthorize("@ss.hasPermi('demo:deposit:export')")
    @Log(title = "竞拍保证金", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuctionDeposit auctionDeposit)
    {
        List<AuctionDeposit> list = auctionDepositService.selectAuctionDepositList(auctionDeposit);
        ExcelUtil<AuctionDeposit> util = new ExcelUtil<AuctionDeposit>(AuctionDeposit.class);
        util.exportExcel(response, list, "竞拍保证金数据");
    }

    /**
     * 获取竞拍保证金详细信息
     */
    @ApiOperation("获取竞拍保证金详细信息")
    @PreAuthorize("@ss.hasPermi('demo:deposit:query')")
    @GetMapping(value = "/{depositId}")
    public AjaxResult getInfo(@ApiParam(value = "竞拍保证金ID", required = true) @PathVariable("depositId") Long depositId)
    {
        return success(auctionDepositService.selectAuctionDepositByDepositId(depositId));
    }

    /**
     * 新增竞拍保证金
     */
    @ApiOperation("新增竞拍保证金")
    @PreAuthorize("@ss.hasPermi('demo:deposit:add')")
    @Log(title = "竞拍保证金", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuctionDeposit auctionDeposit)
    {
        return toAjax(auctionDepositService.insertAuctionDeposit(auctionDeposit));
    }

    /**
     * 修改竞拍保证金
     */
    @ApiOperation("修改竞拍保证金")
    @PreAuthorize("@ss.hasPermi('demo:deposit:edit')")
    @Log(title = "竞拍保证金", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuctionDeposit auctionDeposit)
    {
        return toAjax(auctionDepositService.updateAuctionDeposit(auctionDeposit));
    }

    /**
     * 删除竞拍保证金
     */
    @ApiOperation("删除竞拍保证金")
    @PreAuthorize("@ss.hasPermi('demo:deposit:remove')")
    @Log(title = "竞拍保证金", businessType = BusinessType.DELETE)
	@DeleteMapping("/{depositIds}")
    public AjaxResult remove(@ApiParam(value = "竞拍保证金ID数组", required = true) @PathVariable Long[] depositIds)
    {
        return toAjax(auctionDepositService.deleteAuctionDepositByDepositIds(depositIds));
    }
}
